﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>照片批量采集</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="${pageContext.request.contextPath }/scripts/boot.js" type="text/javascript"></script>
<style type="text/css">
    html, body
    {
        font-size:12px;
        padding:0;
        margin:0;
        border:0;
        height:100%;
    } 
</style>
</head>
<body onload="makeEventid()">
  <form id="form1" method="post" action="${pageContext.request.contextPath}/zpcj.do?method=exkcdate">
  <fieldset style="border:solid 1px #aaa;padding:3px;">
<legend>照片批量采集</legend>
    <input name="eventid" class="mini-hidden"/>
    <div style="padding-bottom:5px;">
      <table style="table-layout:fixed;width:100%;">
        <tr>
          <td style="width:90px;white-space:nowrap;text-align:right;">单位码：</td>
          <td style="width:360px;"><input name="aab001" class="mini-textbox" required="true" onenter="onKeyEnter" vtype="minLength:8" maxlength="8" emptyText="请输入单位码" style="width:50%;"/></td>
          <td style="width:110px;white-space:nowrap;text-align:right;">文件路径：</td>
          <td style="width:500px;" colspan="5"><a class="mini-button" iconCls="icon-upload" onclick="Upload()" style="width:96%">上传</a><!--<input type="file"  name="file0" id="file0" style="width:100%;" />--></td>
        </tr>       
        <tr>
          <td style="width:90px;white-space:nowrap;text-align:right;">单位名称：</td>
          <td style="width:360px;" ><input name="aab004" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="readonly" style="width:100%;"/></td>  
          <td style="width:110px;white-space:nowrap;text-align:right;">正确人数：</td>
          <td style="width:90px;" align="left"><input name="sum1" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="readonly" style="width:80%;"/></td>
          <td style="width:110px;white-space:nowrap;text-align:right;">错误人数：</td>
          <td style="width:90px;"><input name="sum2" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="readonly" style="width:80%;"/></td>
          <td style="width:110px;white-space:nowrap;text-align:right;">导入照片：</td>
          <td style="width:90px"><input name="sum3" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="readonly" style="width:80%;"/></td> 
        </tr>
      </table>
    </div>
        </fieldset>
  </form>
  <div id="tabs1" class="mini-tabs" activeIndex="0"  plain="false">
    <div title="正确数据" >
      <div id="datagrid1" class="mini-datagrid" style="width:100%;height:345px;" allowResize="true"
           url="" idField="id" multiSelect="true">
        <div property="columns">
          <div type="indexcolumn"></div> 
          <div field="aac001" width="120" align="center" headerAlign="center"  >社会保障卡号</div>
          <div field="aac003" width="120" align="center" headerAlign="center"  >姓名</div>
          <div field="aac004" width="120" align="center" headerAlign="center"   >性别</div>
          <div field="aac002" width="120" align="center" headerAlign="center"  >证件号</div>
          <div field="aac005" width="120" align="center" headerAlign="center"  >民族</div>
        </div>
      </div>
    </div>
    <div title="错误数据" >
      <div id="datagrid2" class="mini-datagrid" style="width:100%;height:345px;" allowResize="true"
           url="" idField="id" multiSelect="true">
        <div property="columns">
          <div type="indexcolumn"></div> 
          <div field="aac001" width="120" align="center" headerAlign="center"  >社会保障卡号</div>
          <div field="aac003" width="120" align="center" headerAlign="center"  >姓名</div>
          <div field="aac004" width="120" align="center" headerAlign="center"  >性别</div>
          <div field="aac002" width="120" align="center" headerAlign="center"  >证件号</div>
          <div field="aac005" width="120" align="center" headerAlign="center"  >民族</div>
          <div field="execmsg" width="120" align="center" headerAlign="center"  >错误信息</div>
        </div>
      </div>
    </div>
  </div>
  <div style="text-align:center;padding:10px;">
    <a class="mini-button"  onclick="check" iconCls="icon-download"  style="width:100px;">导入明细</a>
    <a class="mini-button" id="importpics" onclick="importpic" enabled="false" iconCls="icon-download" style="width:100px;">导入照片</a>
    <!--  <a class="mini-button" onclick="reset()"  style="width:100px;">打印照片采集表</a>-->
    <a class="mini-button" id="exportExcels" onclick="exportExcel" enabled="false" iconCls="icon-upload" style="width:100px;white-space:nowrap;">导出错误数据</a>
    <a class="mini-button" onclick="onReset" iconCls="icon-remove"  style="width:100px;">重置</a>
  </div>
<script type="text/javascript">
    mini.parse();
    var grid1 = mini.get("datagrid1");
    var grid2 = mini.get("datagrid2");
    var form = new mini.Form("form1");
     function onKeyEnter()
        {
          var aab001 = mini.getbyName("aab001").getValue().trim();                     
           $.ajax({               
                    url: "/sbk/zpcj.do?method=getunit",
                    cache: false,
                    data:{id:aab001},                                                    
                    success: function (text) {   
                        if(text == "null" || text == null || text == "")  {
                          mini.alert("无效单位码");
                          return;
                        }                                                  
                        mini.getbyName("aab004").setValue(text);                                                              
                    }
                });        
        }
        
          //上传数据文件
    function Upload(){
      $.ajax({               
                    url: "/sbk/zpcj.do?method=getEventid", 
                    async:false,                                                      
                    success: function (text) {                                                  
                    		mini.getbyName("eventid").setValue(text); 
                    		var id=mini.getbyName("eventid").getValue(); 
                    	     mini.open({
               					 url: bootPATH + "../page/upload/upload.jsp",
                				title: "上传附件", width: 600, height: 300,
               					 onload: function () {
                    			var iframe = this.getIFrameEl();
                    			var data = {id:id};
                    			iframe.contentWindow.SetData(data);
                			},
           				 });                                                                                                        
                    }
                });
 
    }

     function check(){
      var eventid=mini.getbyName("eventid").getValue();
        $.ajax({               
                    url: "/sbk/zpcj.do?method=chkzpplcj", 
                    data:{eventid:eventid},                                    
                    success: function (text) { 
                    var o = mini.decode(text);                    
                    if(o.sum1 != 0)
                    {
                       mini.get("importpics").setEnabled(true);
                    }
                    if(o.sum2 != 0) 
                    {
                       mini.get("exportExcels").setEnabled(true);
                    }
                    if(o.sum1 == 0 && o.sum2 == 0)
                    {
                       mini.alert("请导入照片");
                       return;
                    }
                    mini.getbyName("sum1").setValue(o.sum1);                                                                        
                    grid1.setUrl("/sbk/zpcj.do?method=getsuccess&key="+ eventid);
                    grid1.load(); 
                    mini.getbyName("sum2").setValue(o.sum2); 
                    grid2.setUrl("/sbk/zpcj.do?method=getfail&key="+ eventid); 
                    grid2.load();                                                                                                       
                    }
                });    
     }
     
      function makeEventid()
        {           
                     
         $.ajax({               
                    url: "/sbk/zpcj.do?method=getEventid",                                                       
                    success: function (text) {                                                  
                    mini.getbyName("eventid").setValue(text);                                                                                                         
                    }
                });                
        }
        
        function exportExcel()
		{
		    var eventid = mini.getbyName("eventid").getValue().trim();   
		    if(eventid!=""){
		    var form1 = document.getElementById("form1");	
			form1.submit();
		     } 
		     else
		    { 
		       mini.alert("请导入照片");
		    }
		   
		}
        
          function importpic()
        {      
           form.validate();
           if (form.isValid() == false) return;
           if(form.isValid()==true){
      	   mini.mask({el: document.body,cls: 'mini-mask-loading',html: '采集中...'});
      	   }	
      	    var eventid=mini.getbyName("eventid").getValue().trim();
            var aab001 = mini.getbyName("aab001").getValue().trim();	       
            $.ajax({               
                    url: "/sbk/zpcj.do?method=savepic",   
                    data:{eventid:eventid,aab001:aab001},                                   
                    success: function (text) { 
                        var msg = text;
                        mini.unmask(); 
                        if(msg.substring(0,4) == "fail")
                        {
                           mini.alert("照片"+ msg.substring(4,20) +"大小不符，请重新上传！");
                           onReset();
                           return;
                        }                                                  
                        if(text != "0")
                        {
                          mini.alert("照片采集成功");
                          mini.get("importpics").setEnabled(false); 
                          mini.getbyName("sum3").setValue(text);   
                                               
                        }
                        else
                        {
                          mini.alert("照片采集失败");
                        }                                                                                
                    },
                    error : function(jqXHR, textStatus, errorThrown) {
					mini.alert(jqXHR.responseText);					
				  }
                });   
        }
    
      
     function onReset(e) {
     		form.reset();
     		grid1.setUrl("/sbk/zpcj.do?method=getsuccess&key");
     		grid2.setUrl("/sbk/zpcj.do?method=getsuccess&key");
     	    grid1.load();
     		grid2.load();
     		mini.get("importpics").setEnabled(false);
     		mini.get("exportExcels").setEnabled(false);
     		makeEventid();
		}
    
</script>
</body>
</html>
